<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8"/>
</head>

<body>

<script src="cn.js"></script>

<button onclick="checkvariants()">Click me</button>

<script>

var cn = Module.cwrap('hash_cn', 'string', ['string','number','number','number']);

function profile() {
  toTest = "5468697320697320612074657374205468697320697320612074657374205468697320697320612074657374";
  var t0 = performance.now();
  var hash = "0";           // algo, variant, height
  for(i=0;i<10;i++) hash=cn(toTest,3,2,1806260);
  var t1 = performance.now();
  alert("10 cryptonight hashes took " + (t1 - t0) + " milliseconds.")
  alert(hash);
}

function checkvariants() {
  blob = "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000";
  alert(cn(blob,1,0,0)); // 4c3428f39e1f9ecda3b0726fd4f4fca62843597c480f033ae38d113282b273bf

  blob = "11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111113";
  alert(cn(blob,1,1,0)); // c2e3bd88bffd1bd7855af2dae2a52fef6efd36f00db514a6594718c5b67fab21

  blob = "6465206f6d6e69627573206475626974616e64756d";
  alert(cn(blob,0,0,0)); // 2f8e3df40bd11f9ac90c743ca8e32bb391da4fb98612aa3b6cdc639ee00b31f5
  
  blob = "38274c97c45a172cfc97679870422e3a1ab0784960c60514d816271415c306ee3a3ed1a77e31f6a885c3cb";
  alert(cn(blob,0,1,0)); // ed082e49dbd5bbe34a3726a0d1dad981146062b39d36d62c71eb1ed8ab49459b
  
  blob = "5468697320697320612074657374205468697320697320612074657374205468697320697320612074657374";
  alert(cn(blob,0,2,0)); // 353fdc068fd47b03c04b9431e005e00b68c2168a3cc7335c8b9b308156591a4f
  
  blob = "5468697320697320612074657374205468697320697320612074657374205468697320697320612074657374";
  alert(cn(blob,0,3,0)); // 353fdc068fd47b03c04b9431e005e00b68c2168a3cc7335c8b9b308156591a4f
    
  blob = "5468697320697320612074657374205468697320697320612074657374205468697320697320612074657374";
  alert(cn(blob,0,4,1806260)); // f759588ad57e758467295443a9bd71490abff8e9dad1b95b6bf2f5d0d78387bc
  
  blob = "5468697320697320612074657374205468697320697320612074657374205468697320697320612074657374";
  alert(cn(blob,0,5,1806260)); // f759588ad57e758467295443a9bd71490abff8e9dad1b95b6bf2f5d0d78387bc
  
  blob = "4c6f72656d20697073756d20646f6c6f722073697420616d65742c20636f6e73656374657475722061646970697363696e67";
  alert(cn(blob,0,5,1806261)); // 5bb833deca2bdd7252a9ccd7b4ce0b6a4854515794b56c207262f7a5b9bdb566
  
  blob = "757420616c697175697020657820656120636f6d6d6f646f20636f6e7365717561742e20447569732061757465";
  alert(cn(blob,0,5,1806265)); // 1d290443a4b542af04a82f6b2494a6ee7f20f2754c58e0849032483a56e8e2ef
    
  blob = "73756e7420696e2063756c706120717569206f666669636961206465736572756e74206d6f6c6c697420616e696d20696420657374206c61626f72756d2e";
  alert(cn(blob,0,5,1806269)); // 75c6f2ae49a20521de97285b431e717125847fb8935ed84a61e7f8d36a2c3d8e
}


</script>

</body>
</html>
